# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        黄周云  
# Name:         test
# Description:  __dict__成员变量
# Author:       ASUS
# Date:         2019/3/20
#-------------------------------------------------------------------------------


class Myclass:
    def __setattr__(self, name, value):
        if name == 'value':
            if value > 0:
                self.__dict__[name] = value
            else:
                print("{}属性的值必须大于零".format(name))
        else:
            self.__dict__[name] = value

c = Myclass()
c.value = 20              #相对象c动态添加value属性
print("c.value",'=',c.value)
c.value = -43
print("c.value",'=',c.value)
c.abc = 10
print("c.abc",'=',c.abc)


